import { FormSchema } from '/@/components/Form';
import { BasicColumn } from '/@/components/Table';
import { getApplicationList } from '/@/api/application';
import { getTenantAllList } from '/@/api/tenant';

export const searchFormSchema: FormSchema[] = [
  {
    field: 'code',
    component: 'Input',
    label: '企业编码',
    colProps: {
      span: 6,
    },
  },
  {
    field: 'name',
    component: 'Input',
    label: '企业编号',
    colProps: {
      span: 6,
    },
  },
  {
    field: 'createTime',
    component: 'RangePicker',
    label: '创建时间',
    colProps: {
      span: 6,
    },
    componentProps: {
      valueType: 'Date',
    },
  },
];

export const tenantColumns: BasicColumn[] = [
  {
    title: '企业编码',
    align: 'center',
    dataIndex: 'code',
    width: 120,
  },
  {
    title: '企业名称',
    align: 'center',
    width: 100,
    dataIndex: 'name',
  },
  {
    title: '责任人',
    align: 'center',
    width: 100,
    dataIndex: 'duty',
  },
  {
    title: 'logo',
    align: 'center',
    width: 80,
    dataIndex: 'logo',
  },
  {
    title: '状态',
    align: 'center',
    width: 70,
    dataIndex: 'enableStatus',
  },
  {
    title: '有效期',
    align: 'center',
    width: 120,
    dataIndex: 'expirationTime',
  },
  {
    title: '创建日期',
    align: 'center',
    width: 120,
    dataIndex: 'createTime',
  },
];

export const tenantFormSchemas: FormSchema[] = [
  {
    field: 'code',
    component: 'Input',
    label: '企业编码',
    required: true,
  },
  {
    field: 'name',
    component: 'Input',
    label: '企业名称',
    required: true,
  },
  {
    field: 'duty',
    component: 'Input',
    label: '责任人',
    required: true,
  },
  {
    field: 'logo',
    label: 'logo',
    component: 'JImageUpload',
  },
  {
    field: 'enableStatus',
    component: 'Select',
    label: '状态',
    required: true,
    componentProps: {
      options: [
        { label: '启用', value: 1 },
        { label: '禁用', value: 2 },
      ],
    },
  },
  {
    field: 'expirationTime',
    component: 'DatePicker',
    label: '有效期',
    required: true,
  },
];

export const applicationSearchFormSchema: FormSchema[] = [
  {
    field: 'tenantName',
    component: 'Input',
    label: '企业名称',
    colProps: {
      span: 6,
    },
  },
  {
    field: 'createTime',
    component: 'RangePicker',
    label: '创建时间',
    colProps: {
      span: 6,
    },
    componentProps: {
      valueType: 'Date',
    },
  },
];

export const tenantApplicationColumns: BasicColumn[] = [
  {
    title: '企业编码',
    align: 'center',
    dataIndex: 'tenantCode',
    width: 120,
  },
  {
    title: '企业名称',
    align: 'center',
    dataIndex: 'tenantName',
    width: 120,
  },
  {
    title: '应用名称',
    align: 'center',
    dataIndex: 'applicationName',
    width: 120,
  },
  {
    title: '同步状态',
    align: 'center',
    width: 100,
    dataIndex: 'synStatus',
  },
  {
    title: '同步时长',
    align: 'center',
    width: 120,
    dataIndex: 'executionSynLong',
  },
  {
    title: '上次同步时间',
    align: 'center',
    width: 120,
    dataIndex: 'lastSynTime',
  },

  {
    title: '创建日期',
    align: 'center',
    width: 120,
    dataIndex: 'createTime',
  },
];

export const tenantApplicationFormSchemas: FormSchema[] = [
  {
    field: 'tenantId',
    component: 'ApiSelect',
    label: '企业',
    required: true,
    componentProps: {
      api: getTenantAllList,
      labelField: 'name',
      valueField: 'id',
    },
  },
  {
    field: 'applicationId',
    component: 'ApiSelect',
    label: '应用',
    required: true,
    componentProps: {
      api: getApplicationList,
      labelField: 'name',
      valueField: 'id',
    },
  },
];
